package org.logMonitor.service.impl;

import org.logMonitor.dao.RuleDao;
import org.logMonitor.dao.cache.RedisDao;
import org.logMonitor.dto.ChinaMap;
import org.logMonitor.dto.Exposer;
import org.logMonitor.dto.Map2city;
import org.logMonitor.entity.Rule;
import org.logMonitor.service.RuleService;
import org.logMonitor.utils.AddressUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * Created by lenovo on 2018/1/18.
 */
@Service
public class RuleServiceImpl implements RuleService{

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private RuleDao ruleDao;
    @Autowired
    private RedisDao redisDao;
    /**
     * rule默认都是0
     * @param rule
     * @return
     */
    public int addRule(Rule rule) {
        return ruleDao.addRule(rule);
    }

    public int deletRule(int ruleId) {
        return ruleDao.deleteRule(ruleId);
    }

    public int updateRule(Rule rule) {

        return 0;
    }

    public List<Rule> getAllRule() {
        return ruleDao.getAllRule();
    }

    public Rule getRuleById(int ruleId) {
        return ruleDao.getRuleById(ruleId);
    }

    public Map2city getChinaMapDateByRuleId(int ruleId)  {
        Map2city chinaMapList = null;
        chinaMapList = redisDao.getRuleIdFromRedis(ruleId);
        return chinaMapList;
    }

    public int openRule(int ruleId) {
        return ruleDao.openRule(ruleId);
    }

    public int closeRule(int ruleId) {
        return ruleDao.closeRule(ruleId);
    }
}
